<template>
  <div>
    <h2>添加投资</h2>
    <table class="table table-bordered">
      <tr>
        <td>投资名称</td>
        <td>
          <input type="text" v-model="sdate.I_Name" />
        </td>
      </tr>
      <tr>
        <td>投资总额度</td>
        <td>
          <input type="text" v-model="sdate.I_Zong" />
        </td>
      </tr>
      <tr>
        <td></td>
        <td><input type="button" value="添加投资" @click="add" /></td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
let router = useRouter();

let data = reactive({
  sdate: {
    I_Name: '',
    I_Zong: '',
  },
});
let { sdate } = toRefs(data);

const add = () => {
  axios({
    url: 'http://localhost:61995/api/User/Add',
    method: 'post',
    data: {
      I_Name: sdate.value.I_Name,
      I_Zong: sdate.value.I_Zong,
    },
  }).then((res) => {
    console.log(res.data);
    if (res.data.data > 0) {
      alert('添加成功');
      router.push('/show');
    }
  });
};
</script>

<style scoped></style>
